
package org.hw.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 
 * @TableName file
 * @description 文件管理 文件记录表
 */
@Data
@TableName("file")
@ApiModel
public class File implements Serializable {
    
    /**
     * 名称
	 * 
     */
    @ApiModelProperty("名称")
    private String filename;
				
    /**
     * 类型
	 * 
     */
    @ApiModelProperty("类型")
    private String mimetype;
				
    /**
     * 原名称
	 * 
     */
    @ApiModelProperty("原名称")
    private String originalname;
				
    /**
     * 大小
	 * 
     */
    @ApiModelProperty("大小")
    private Integer size;
				
    /**
     * 是否需要授权
	 * 
     */
    @ApiModelProperty("是否需要授权")
    private Integer authorization;
				
	/**
	 * ID
	 */
	@TableId(type = IdType.ASSIGN_ID)
	@ApiModelProperty("ID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;
			
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long createTime;
				  
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	private String createTimeString;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long updateTime;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	private String updateTimeString;
					
	/**
	 * 逻辑删除控制
	 */
	@ApiModelProperty("逻辑删除控制")
	@TableLogic
	private Integer state;
			  
	/**
	 * 单位
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("单位")
	private String unitId;
					
	
	/**
	 * 设置名称
	 */
	public void setFilename(String filename){
		this.filename = filename;
	}

	/**
	 * 获取名称
	 */
	public String getFilename(){
		return this.filename;
	}
		
	/**
	 * 设置类型
	 */
	public void setMimetype(String mimetype){
		this.mimetype = mimetype;
	}

	/**
	 * 获取类型
	 */
	public String getMimetype(){
		return this.mimetype;
	}
		
	/**
	 * 设置原名称
	 */
	public void setOriginalname(String originalname){
		this.originalname = originalname;
	}

	/**
	 * 获取原名称
	 */
	public String getOriginalname(){
		return this.originalname;
	}
		
	/**
	 * 设置大小
	 */
	public void setSize(Integer size){
		this.size = size;
	}

	/**
	 * 获取大小
	 */
	public Integer getSize(){
		return this.size;
	}
		
	/**
	 * 设置是否需要授权
	 */
	public void setAuthorization(Integer authorization){
		this.authorization = authorization;
	}

	/**
	 * 获取是否需要授权
	 */
	public Integer getAuthorization(){
		return this.authorization;
	}
		
	/**
	 * 设置ID
	 */
	public void setId(Long id){
		this.id = id;
	}

	/**
	 * 获取ID
	 */
	public Long getId(){
		return this.id;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTime(Long createTime){
		this.createTime = createTime;
	}

	/**
	 * 获取创建时间
	 */
	public Long getCreateTime(){
		return this.createTime;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTimeString(String createTimeString){
		this.createTimeString = createTimeString;
	}

	/**
	 * 获取创建时间
	 */
	public String getCreateTimeString(){
		return this.createTimeString;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTime(Long updateTime){
		this.updateTime = updateTime;
	}

	/**
	 * 获取更新时间
	 */
	public Long getUpdateTime(){
		return this.updateTime;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTimeString(String updateTimeString){
		this.updateTimeString = updateTimeString;
	}

	/**
	 * 获取更新时间
	 */
	public String getUpdateTimeString(){
		return this.updateTimeString;
	}
		
	/**
	 * 设置逻辑删除控制
	 */
	public void setState(Integer state){
		this.state = state;
	}

	/**
	 * 获取逻辑删除控制
	 */
	public Integer getState(){
		return this.state;
	}
		
	/**
	 * 设置单位
	 */
	public void setUnitId(String unitId){
		this.unitId = unitId;
	}

	/**
	 * 获取单位
	 */
	public String getUnitId(){
		return this.unitId;
	}
		
	public String stringify(){
		String rc = "{\"filename\":\"" + this.getFilename() + "\",\"mimetype\":\"" + this.getMimetype() + "\",\"originalname\":\"" + this.getOriginalname() + "\",\"size\":\"" + this.getSize() + "\",\"authorization\":\"" + this.getAuthorization() + "\",\"id\":\"" + this.getId() + "\",\"createTime\":\"" + this.getCreateTime() + "\",\"createTimeString\":\"" + this.getCreateTimeString() + "\",\"updateTime\":\"" + this.getUpdateTime() + "\",\"updateTimeString\":\"" + this.getUpdateTimeString() + "\",\"state\":\"" + this.getState() + "\",\"unitId\":\"" + this.getUnitId() + "\"}";
		rc = rc.replaceAll("\"null\"","null").replaceAll("\"([0-9]+)\"","$1");
        return rc;
	}

	public static File JSONparse(String jsonString) throws JsonProcessingException {
        if(jsonString == null) return null;
		try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.readValue(jsonString,File.class);
        }catch (JsonProcessingException e){
            return null;
        }
    }
}
    